/*****************************************************
*                                                                          
*               COPYRIGHT (c) 2015-2017 Broadlink Corporation              
*                         All Rights Reserved                              
*                                                                          
* The source code contained or described herein and all documents          
* related to the source code ("Material") are owned by Broadlink         
* Corporation or its licensors.  Title to the Material remains             
* with Broadlink Corporation or its suppliers and licensors.               
*                                                                          
* The Material is protected by worldwide copyright and trade secret        
* laws and treaty provisions. No part of the Material may be used,         
* copied, reproduced, modified, published, uploaded, posted, transmitted,  
* distributed, or disclosed in any way except in accordance with the       
* applicable license agreement.                                            
*                                                                          
* No license under any patent, copyright, trade secret or other            
* intellectual property right is granted to or conferred upon you by       
* disclosure or delivery of the Materials, either expressly, by            
* implication, inducement, estoppel, except in accordance with the         
* applicable license agreement.                                            
*                                                                          
* Unless otherwise agreed by Broadlink in writing, you may not remove or   
* alter this notice or any other notice embedded in Materials by Broadlink 
* or Broadlink's suppliers or licensors in any way.                        
*                                                                          
** Author: 
** Date: 2018-03-23
*
*****************************************************/

#ifndef __DNA_XZ_DEC_H_
#define __DNA_XZ_DEC_H_

#ifdef __cplusplus
extern "C"{
#endif

/***** INCLUDES *************************************/

/***** TYPEDEFS *************************************/
/**
 * struct xz_buf - Passing input and output buffers to XZ code
 * @in:         Beginning of the input buffer. This may be NULL if and only
 *              if in_pos is equal to in_size.
 * @in_pos:     Current position in the input buffer. This must not exceed
 *              in_size.
 * @in_size:    Size of the input buffer
 * @out:        Beginning of the output buffer. This may be NULL if and only
 *              if out_pos is equal to out_size.
 * @out_pos:    Current position in the output buffer. This must not exceed
 *              out_size.
 * @out_size:   Size of the output buffer
 *
 * Only the contents of the output buffer from out[out_pos] onward, and
 * the variables in_pos and out_pos are modified by the XZ code.
 */
typedef struct dna_xz_buf 
{
	const unsigned char	*in;
	unsigned int		in_pos;
	unsigned int		in_size;

	unsigned char		*out;
	unsigned int		out_pos;
	unsigned int		out_size;
} dna_xz_buf_t;

/***** DEFINES **************************************/
enum dna_xz_ret
{
	DNA_XZ_OK,
	DNA_XZ_STREAM_END,
	DNA_XZ_UNSUPPORTED_CHECK,
	DNA_XZ_MEM_ERROR,
	DNA_XZ_MEMLIMIT_ERROR,
	DNA_XZ_FORMAT_ERROR,
	DNA_XZ_OPTIONS_ERROR,
	DNA_XZ_DATA_ERROR,
	DNA_XZ_BUF_ERROR
};

/***** CONSTANTS ************************************/

/***** VARIABLES ************************************/

/***** EXTERNAL VARIABLES ***************************/

/***** EXTERNAL FUNCTIONS ***************************/

/***** PROTOTYPES ***********************************/
int dna_xz_dec_init(dna_xz_buf_t *stream, unsigned char *inbuf, unsigned char *outbuf);
int dna_xz_dec_stream(dna_xz_buf_t *stream, 
					unsigned char *inbuf, unsigned int inlen, 
					unsigned char *outbuf, unsigned int outlen, 
					unsigned int *decomp_len);
void dna_xz_dec_end(void);


#ifdef __cplusplus
}
#endif

#endif /* __DNA_XZ_DEC_H_ */

